package com.frkj.yuan.view;

import android.annotation.SuppressLint;
import android.content.Context;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.OrientationHelper;
import androidx.recyclerview.widget.RecyclerView;

/**
 * 作者：菲菲 on 2020/6/19 11:08
 * <p>
 *  RecyclerViews布局加载相关设置
 * company：中星电子
 */
public class RecyclerViewLayoutManager {

    /**
     * @param context
     * @param recyclerView
     * recyclerview 设置垂直线性布局
     */
    @SuppressLint("WrongConstant")
    public static void setLinearVerticalManager(Context context, RecyclerView recyclerView) {
        ScrollLinearLayoutManager mManager = new ScrollLinearLayoutManager(context);
        recyclerView.setLayoutManager(mManager);
        recyclerView.setNestedScrollingEnabled(false);
        mManager.setOrientation(OrientationHelper.VERTICAL);
    }

    /**
     * @param context
     * @param recyclerView
     * recyclerview 设置水平线性布局
     */
    @SuppressLint("WrongConstant")
    public static void setLinearHorizontalManager(Context context, RecyclerView recyclerView) {
        ScrollLinearLayoutManager mManager = new ScrollLinearLayoutManager(context);
        recyclerView.setLayoutManager(mManager);
        recyclerView.setNestedScrollingEnabled(false);
        mManager.setOrientation(OrientationHelper.HORIZONTAL);
    }

    /**
     * @param context
     * @param recyclerView
     * recyclerview 设置垂直线性布局，添加下划线
     */
    @SuppressLint("WrongConstant")
    public static void setLinearVerticalItemDecorationManager(Context context, RecyclerView recyclerView) {
        ScrollLinearLayoutManager mManager = new ScrollLinearLayoutManager(context);
        recyclerView.setLayoutManager(mManager);
        recyclerView.setNestedScrollingEnabled(false);
        recyclerView.addItemDecoration(new DividerItemDecoration(context, 1));
        mManager.setOrientation(OrientationHelper.VERTICAL);
    }
    /**
     * @param context
     * @param recyclerView
     * recyclerview 设置水平线性布局，加下划线
     */
    @SuppressLint("WrongConstant")
    public static void setLinearHorizontalItemDecorationManager(Context context, RecyclerView recyclerView) {
        ScrollLinearLayoutManager mManager = new ScrollLinearLayoutManager(context);
        recyclerView.setLayoutManager(mManager);
        recyclerView.setNestedScrollingEnabled(false);
        recyclerView.addItemDecoration(new DividerItemDecoration(context, 1));
        mManager.setOrientation(OrientationHelper.HORIZONTAL);
    }

    /**
     * @param context
     * @param recyclerView
     * @param number
     * recyclerview 设置垂直网格布局
     */
    @SuppressLint("WrongConstant")
    public static void setGridLayoutManager(Context context, RecyclerView recyclerView, int number) {
        ScrollGridLayoutManager mManager = new ScrollGridLayoutManager(context, number);
        recyclerView.setLayoutManager(mManager);
        recyclerView.setNestedScrollingEnabled(false);
        mManager.setOrientation(OrientationHelper.VERTICAL);
    }

    /**
     * @param context
     * @param recyclerView
     * @param number
     * recyclerview 设置垂直网格布局，加九宫格下划线
     */
    @SuppressLint("WrongConstant")
    public static void setGridItemDecorationManager(Context context, RecyclerView recyclerView, int number) {
        ScrollGridLayoutManager mManager = new ScrollGridLayoutManager(context, number);
        recyclerView.setLayoutManager(mManager);
        recyclerView.setNestedScrollingEnabled(false);
        recyclerView.addItemDecoration(new GridDividerItemDecoration(context));
        mManager.setOrientation(OrientationHelper.VERTICAL);
    }
}
